package com.example.fx.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.ExplosiveMoney
import com.example.fx.R

class MoneyAdapter:BaseQuickAdapter<ExplosiveMoney,BaseViewHolder>(R.layout.item_money) {
    var selectType = 4//设置默认选中的type值为4
    override fun convert(holder: BaseViewHolder, item: ExplosiveMoney) {
        holder.setText(R.id.money_tv,item.name)
        if(item.type.toInt()==selectType){
            holder.getView<TextView>(R.id.money_tv).setTextColor(Color.RED)
        }else{
            holder.getView<TextView>(R.id.money_tv).setTextColor(Color.GRAY)
        }
    }
    //更新选中的type值
    fun setType(type:Int){
        selectType = type
        notifyDataSetChanged()//别忘了刷新适配器
    }
}